<?php
// 导入配置文件+配置类
require './configs/config.php';
/*require './models/Model.class.php';

require './controllers/IndexControllers.class.php';
require './controllers/UserControllers.class.php';
require './controllers/GoodsControllers.class.php';

*/
// 自动加载类
   function  mvc_autoload($classname){
   	// echo $classname;
	if (file_exists("./models/{$classname}.class.php")) {
		require "./models/{$classname}.class.php";
	}elseif (file_exists("./controllers/{$classname}.class.php")) {
		require "./controllers/{$classname}.class.php";
	}else{
		header("HTTP/1.0 404 not found");
        header("Status: 404 not found");
		echo '<h1>404 not found</h1>';
		exit();
	}
}
// 导入模板引擎
require './libs/Smarty.class.php';
spl_autoload_register('mvc_autoload');
$smarty = new Smarty();

// 获取控制器名
$c = (!empty($_GET['c']))?$_GET['c']:'Index';
$a = (!empty($_GET['a']))?$_GET['a']:'index'; 

// 拼装类名
$classname = $c.'Controller';
// 实例化控制器
$controller = new $classname();
// var_dump($controller);
$controller->$a();
